#!/bin/bash
inits(){
    mkdir -p /etc/xiandian/
echo '##--------------------system Config--------------------##
##Controller Server Manager IP. example:x.x.x.x
HOST_IP=10.1.1.12
 
##Controller Server hostname. example:controller
HOST_NAME=controller
 
##Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=10.1.1.14
 
##Compute Node hostname. example:compute
HOST_NAME_NODE=compute
##--------------------Rabbit Config ------------------##
##user for rabbit. example:openstack
RABBIT_USER=openstack
 
##Password for rabbit user .example:000000
RABBIT_PASS=000000
 
##--------------------MySQL Config---------------------##
##Password for MySQL root user . exmaple:000000
DB_PASS=000000
 
##--------------------Keystone Config------------------##
##Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
 
##Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=000000
 
##--------------------Glance Config--------------------##
##Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=000000
 
##Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000
 
##--------------------Nova Config----------------------##
##Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000
 
##Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000
 
##--------------------Neturon Config-------------------##
##Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000
 
##Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000
 
##metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000
 
##External Network Interface. example:eth1
INTERFACE_NAME=ens33
 
##First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
#minvlan=
 
##Last Vlan ID in VLAN RANGE for VLAN Network. example:200
#maxvlan=
 
##--------------------Cinder Config--------------------##
##Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=000000
 
##Password for Keystore cinder user. exmaple:000000
CINDER_PASS=000000
 
##Cinder Block Disk. example:md126p3
#BLOCK_DISK=
 
##--------------------Trove Config--------------------##
##Password for Mysql Trove User. exmaple:000000
TROVE_DBPASS=000000
 
##Password for Keystore Trove User. exmaple:000000
TROVE_PASS=000000
 
##--------------------Swift Config---------------------##
##Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000
 
##The NODE Object Disk for Swift. example:md126p4.
#OBJECT_DISK=
 
##The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=
 
##--------------------Heat Config----------------------##
##Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=000000
 
##Password for Keystore heat user. exmaple:000000
HEAT_PASS=000000
 
##--------------------Ceilometer Config----------------##
##Password for Mysql ceilometer user. exmaple:000000
CEILOMETER_DBPASS=000000
 
##Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=000000
 
##--------------------AODH Config----------------##
##Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=000000
 
##Password for Keystore AODH user. exmaple:000000
AODH_PASS=000000' > /etc/xiandian/openrc.sh
source /etc/xiandian/openrc.sh
bash iaas-pre-host.sh
}
insta(){
    cp ./*.sh /usr/bin/
    chmod 777 /usr/bin/*.sh
    iaas-install-mysql.sh
    iaas-install-keystone.sh
    iaas-install-glance.sh
    iaas-install-nova-controller.sh
    iaas-install-neutron-controller.sh
    iaas-install-neutron-controller-gre.sh
    iaas-install-dashboard.sh
}
if [[ -f "/etc/xiandian/openrc.sh" ]];then
    insta
else
    inits
fi
